package cn.com.pansky.action.outer;

import net.vsame.url2sql.action.CommonAction;
import cn.com.pansky.service.CommonService;
import cn.com.pansky.util.SendMsgUtil;

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;

public class SendMsgAction extends CommonAction  {
	CommonService cs = new CommonService();
	
	
	public void sendMsg(){
		String AA032 = getParam("AA032");
		try {
			System.out.println(cs.aliyunSms(AA032));
		} catch (Exception e) {
			e.printStackTrace(); 
		}
	}
	
	public void commSend(){
		SendMsgUtil sendmsg = new SendMsgUtil();
		JSONObject json = JSONObject.parseObject(context.getParam("param"));
		String phone = context.getParam("phone");
		String templateCode = context.getParam("templateCode");
		
		Boolean rs = false;
		try {
			rs = sendmsg.aliSmsComm(phone, json, templateCode);
		} catch (ClientException e) {
			e.printStackTrace();
			context.putError(-112, "调用短信接口异常，请联系管理员！");
		}
		
		int code = rs ? 0: 1;
		context.put("code", code);
	}
	
	
	
}
